package ngames.com.sushitv.temp.Presenter;

import android.os.Handler;
import android.os.Message;

import ngames.com.sushitv.temp.Interface.TagInterface;
import ngames.com.sushitv.temp.Interface.TagTaskInterface;
import ngames.com.sushitv.temp.Module.TagFractory;


/**
 * Created by edmond on 16-8-1.
 */
public class TagPresenter implements TagTaskInterface {
    private TagFractory tagFractory;
    private TagInterface view;

    private Handler handler = new Handler(){
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what){
                case 0:
                    view.initedData();
                    break;
                case 1:
                    view.moredData();
                    break;
                case 2:
                    view.refreshedData();
                    break;
            }
        }
    };

    public TagPresenter(TagInterface view,TagFractory tagFractory){
        this.view = view;
        this.tagFractory = tagFractory;
    }

    @Override
    public void initData() {
        tagFractory.initData(view.getTagsList(),handler);
    }

    @Override
    public void moreData() {
        tagFractory.moreData(view.getTagsList(),handler);
    }

    @Override
    public void refeshData() {
        tagFractory.refreshData(view.getTagsList(),handler);
    }
}
